package com.itheima.chapter08.set;

import java.util.Iterator;
import java.util.Set;
import java.util.TreeSet;
//Set基本使用
public class setdemo {
    public static void main(String[] args) {
        Set<String> set =new TreeSet<>();
        set.add("bbb");
        set.add("aaa");
        set.add("ddd");
        set.add("aaa");
        System.out.println(set);
        Iterator<String> it = set.iterator();
        while (it.hasNext()){
            System.out.println(it.next());
        }
        System.out.println("---------------------");
        for (String s : set) {
            System.out.println(s);
        }

    }
}
